<template>
  <view :style="themeColor">
    <view class="page">
      <!---flex布局flex布局开始-->
      <view class="flex flex-wrap align-center justify-center benben-flex-layout codeLogin_flex_0">
        <image class='codeLogin_fd0_0' mode="aspectFit" :src='STATIC_URL+"19.png"'></image>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center codeLogin_flex_1">
        <view>
          <benben-flex-tabs class-name='codeLogin_benbenTabsfd1_0' v-model="tabls" ref="benben_tabsfd1_0"
            select-mark="benben_tabsfd1_0" key="benben_tabsfd1_0" :open-title-type='false' :open-sticky='true' :top='0'
            :is-show-content='false' :scrollspy='false' :tabs-info.sync="tabsInfofd1_0">

            <scroll-view @scroll="tabsInfofd1_0.scrollX = $event.detail.scrollLeft" id="benben_tabsfd1_0"
              class="benben-tabs" style="width:750rpx" :scroll-x="true" :scroll-left.sync="tabsInfofd1_0.moveX"
              scroll-with-animation="all .3s ease">
              <view class="benben-tabs-content" id="benben_tabsfd1_0-content">
                <view id="benben_tabsfd1_0-title" class="benben-tabs-title flex align-center flex ">
                  <!-- <view
                    :class="{ 'checkTitlefd1_0': tabls == 'account', 'flex flex-wrap align-center codeLogin_titlefd1_0_c3': true }"
                    @tap="tabls = 'account'" :id="`benben_tabsfd1_0-title-item-${'account'}`">

                    <text>{{$t('手机号登录')}}</text>

                  </view> -->
                  <view
                    :class="{ 'checkTitlefd1_0': tabls == 'email', 'flex flex-wrap align-center codeLogin_titlefd1_0_c4': true }"
                    @tap="tabls = 'email'" :id="`benben_tabsfd1_0-title-item-${'email'}`">

                    <text>{{$t('邮箱号登录')}}</text>

                  </view>
                </view>
                <view :style="{ left: tabsInfofd1_0.lineleft, maxWidth: tabsInfofd1_0.lineWidth ,}"
                  id="benben_tabsfd1_0-line" class="benben-tabs-line flex benben-flex-tabs-line codeLogin_linefd1_0">
                </view>
              </view>
            </scroll-view>

          </benben-flex-tabs>

        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout codeLogin_flex_2">
        <view class='flex flex-wrap align-center codeLogin_fd2_0' v-if=" tabls=='account'">
          <image class='codeLogin_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"64.png"'></image>
          <view class='flex flex-wrap align-center codeLogin_fd1_3_c1' @click.stop="pickerDiy1704874099380=true">
            <text class='codeLogin_fd1_3_c1_c0'>+{{area_code}}</text>
            <!-- <image class='codeLogin_fd1_3_c1_c1' mode="aspectFit" :src='STATIC_URL+"1111.png"'></image> -->
          </view>
          <input class='flex-sub codeLogin_fd2_0_c1' type="number" :placeholder="$t('请输入手机号')" confirm-type="done"
            :maxlength="20" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx"
            v-model="dataObj.actount" />
        </view>
        <view class='flex flex-wrap align-center codeLogin_fd2_0' v-if=" tabls=='email'">
          <image class='codeLogin_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"185.png"'></image>
          <input class='flex-sub codeLogin_fd2_0_c1' type="text" :placeholder="$t('请输入邮箱')" confirm-type="done"
            :maxlength="-1" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx" v-model="dataObj.mail" />
        </view>
        <view class='flex flex-wrap align-center codeLogin_fd2_0'>
          <image class='codeLogin_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"78.png"'></image>
          <input class='flex-sub codeLogin_fd2_0_c1' type="number" :placeholder="$t('请输入验证码')" confirm-type="done"
            :maxlength="4" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx" v-model="code" />
          <benben-send-verification-code ref="vCode1702821369459" class='codeLogin_fd2_2_c2' :after-text="$t('后重新获取')"
            :areacode="area_code" :before-text="$t('获取验证码')" :emptye-text="$t('请输入账号')" :validate-text="$t('请输入正确账号')"
            account-type='phone' :auto='true' type='3' :phone="dataObj.actount"
            v-if=" tabls=='account'"></benben-send-verification-code>
          <benben-send-verification-code ref="vCode1703557924427" class='codeLogin_fd2_2_c2' :after-text="$t('后重新获取')"
            :before-text="$t('获取验证码')" :emptye-text="$t('请输入邮箱号')" :validate-text="$t('请输入正确邮箱号')" account-type='email'
            :auto='true' type='3' :phone="dataObj.mail" v-if=" tabls=='email'"></benben-send-verification-code>
        </view>
        <view class='flex flex-wrap align-center justify-end codeLogin_fd2_3' @tap.stop="handleJumpDiy"
          data-type="navigateTo" :data-url="`/pages/tabBar/loginPage/loginPage`">
          <text class='codeLogin_fd2_3_c0'>{{$t('密码登录')}}</text>
        </view>
        <view class='flex flex-wrap align-center justify-center codeLogin_fd2_4'>
          <button class='codeLogin_fd2_4_c0' @tap.stop="ValidationlLginFunc()">{{$t('登录')}}</button>
        </view>
        <view class='flex flex-wrap align-center justify-center codeLogin_fd2_4'>
          <text class='codeLogin_fd2_5_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/registerPage/registerPage`">{{$t('注册账号')}}</text>
          <text class='codeLogin_fd2_5_c1'>|</text>
          <text class='codeLogin_fd2_5_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/forgotPasswordPage/forgotPasswordPage`">{{$t('忘记密码')}}</text>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!-- <view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex codeLogin_flex_3">
        <view class='flex flex-direction flex-wrap align-stretch flex-sub'>
          <view class='flex flex-wrap align-center justify-center'>

            <view class='flex  codeLogin_fd3_0_c0_c0'></view>

            <text class='codeLogin_fd3_0_c0_c1'>{{$t('快捷登录')}}</text>

            <view class='flex  codeLogin_fd3_0_c0_c0'></view>

          </view>
          <view class='flex flex-wrap align-center justify-center codeLogin_fd3_0_c1'>
            <image class='codeLogin_fd3_0_c1_c0' mode="aspectFit" :src='STATIC_URL+"26.png"'></image>
          </view>
        </view>

      </view> -->
      <view :style="{height: '253rpx'}"></view>
      <benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1704874099380" :value.sync='area_code'
        :options='areaList' mode='selector' :mask-show='true' :timeout='true' :picker-height='88' default-type='name'
        :default-props='{"label":"name","value":"name"}'>
        <template #picker-header>
          <view class='flex flex-wrap align-center justify-between myProfile_picker2_0'>
            <text class='myProfile_picker2_0_c0' @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</text>
            <text>选择区号</text>
            <text class='myProfile_picker2_0_c2' @tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确认</text>
          </view>
        </template>
      </benben-picker>

    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "tabsInfofd1_0": {
          lineleft: '',
          lineWidth: '',
          moveX: 0,
          scrollX: 0,
          PageScrollX: 0
        },
        "tabls": "email",
        "dataObj": {
          "actount": "",
          "mail": "",
          "paswarld": "",
          "is_tick": false
        },
        "code": "",
        "data": {
          "userinfo": {
            "user_token": "",
            "id": "",
            "avatar": "",
            "real_name": "",
            "nickname": "",
            "email": "",
            "gender": "",
            "mobile": "",
            "birthday": "",
            "client_id": "",
            "phone": ""
          }
        },
        areaList: [],
        area_code: '',
        pickerDiy1704874099380: false,
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.$api.post(global.apiUrls.post66178b95a1d2b).then(res => {
        if (res.data.code == 1) {
          this.areaList = res.data.data
          this.area_code = this.areaList[0].name
        }
      })
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //效验登录
      async ValidationlLginFunc() {
        if (this.tabls == 'account') {
          if (!validate(this.dataObj.actount, 'require')) {
            this.$message.info(global.i18n.t('手机号不能为空'));
            return false;
          }
          // if (!validate(this.dataObj.actount, 'phone')) {
          //   this.$message.info(global.i18n.t('请输入正确的手机号'));
          //   return false;
          // }
          this.dataObj.mail = ''
        } else if (this.tabls == 'email') {
          if (!validate(this.dataObj.mail, 'require')) {
            this.$message.info(global.i18n.t('邮箱号不能为空'));
            return false;
          }
          if (!validate(this.dataObj.mail, 'email')) {
            this.$message.info(global.i18n.t('请输入正确的邮箱号'));
            return false;
          }
          this.dataObj.actount = ''
        }
        if (!validate(this.code, 'require')) {
          this.$message.info(global.i18n.t('验证码不能为空'));
          return false;
        }
        if (!validate(this.code, 'captcha')) {
          this.$message.info(global.i18n.t('请输入正确的验证码'));
          return false;
        }
        //请求方法
        //数据验证

        let datadata = await this.$api.post(global.apiUrls.post5c78dca45ebc1, {
          mobile: this.dataObj.actount,
          code: this.code,
          type: '0',
          email: this.dataObj.mail,
          mobile_code: this.area_code
        });

        if (datadata.data.code != 1) {
          this.$message.info(datadata.data.msg);
          return
        }
        let infodata = datadata.data;
        this.data = infodata.data

        this.$store.commit('saveToken', this.data.userinfo.user_token)
        this.$store.commit('updateUserInfo', this.data.userinfo)
        if (this.data.userinfo.leixing == '-1') {
          uni.redirectTo({
            url: `/pages/dlzc/chooseType/chooseType`
          })
        } else {
          this.toHomeDiy();
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .codeLogin_fd1_3_c1_c1 {
    width: 14rpx;
    height: 8rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_fd1_3_c1_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
    margin: 0rpx 10rpx 0rpx 0rpx;
  }

  .codeLogin_fd1_3_c1 {
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .myProfile_picker2_0_c2 {
    color: rgba(100, 80, 235, 1);
  }

  .myProfile_picker2_0_c0 {
    color: var(--benbenFontColor2);
  }

  .myProfile_picker2_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
    border-radius: 25rpx 25rpx 0rpx 0rpx;
    background-size: 100% auto !important;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    // background: url(image-path('21.png')) no-repeat, #F7F3ED;
    background-color: #FFF;
    background-size: 100% auto;
  }

  .codeLogin_flex_0 {
    padding: 105rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_fd0_0 {
    width: 136rpx;
    height: 141rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_flex_1 {
    margin: 87rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_titlefd1_0_c4 {
    margin: 0rpx 0rpx 0rpx 48rpx;
  }

  .codeLogin_titlefd1_0_c3 {
    margin: 0rpx 0rpx 0rpx 64rpx;
  }

  .codeLogin_linefd1_0 {
    background: #3A87F9;
    width: 120rpx;
    height: 8rpx;
    top: 80rpx;
    background-size: 100% auto !important;
    border-radius: 44rpx;
  }

  .checkTitlefd1_0 {
    font-weight: 700 !important;
    font-size: 28rpx !important;
    color: #333 !important;
  }

  ::v-deep .codeLogin_benbenTabsfd1_0 {
    width: 750rpx;
    height: 90rpx;
    white-space: nowrap;
    text-align: center;
    font-size: 28rpx;
    font-weight: 500;
    color: #666666;
  }

  .codeLogin_flex_2 {
    padding: 0rpx 64rpx 0rpx 64rpx;
    margin: 55rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_fd2_5_c1 {
    color: #666666;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 34rpx;
    margin: 0rpx 20rpx 0rpx 20rpx;
  }

  .codeLogin_fd2_5_c0 {
    color: #666666;
    font-size: 36rpx;
    font-weight: 400;
    line-height: 34rpx;
  }

  .codeLogin_fd2_4_c0 {
    background: #3A87F9;
    border-radius: 44rpx;
    width: 616rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }

  .codeLogin_fd2_4 {
    margin: 40rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_fd2_3_c0 {
    color: #4177DD;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .codeLogin_fd2_3 {
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_fd2_2_c2 {
    line-height: 42rpx;
    text-align: center;
    font-size: 27rpx;
    color: #4177DD;
  }

  .codeLogin_fd2_0_c1 {
    font-size: 28rpx;
    color: #333;
  }

  .codeLogin_fd2_0_c0 {
    width: 36rpx;
    height: 36rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 32rpx 0rpx 0rpx;
  }

  .codeLogin_fd2_0 {
    border-bottom: 1px solid rgba(232, 229, 216, 1);
    padding: 32rpx 0rpx 32rpx 0rpx;
  }

  .codeLogin_flex_3 {
    width: 750rpx;
    height: 253rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(42rpx + var(--window-bottom));
  }

  .codeLogin_fd3_0_c1_c0 {
    width: 80rpx;
    height: 80rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_fd3_0_c1 {
    margin: 40rpx 0rpx 0rpx 0rpx;
  }

  .codeLogin_fd3_0_c0_c1 {
    color: #999999;
    font-size: 26rpx;
    font-weight: 400;
    line-height: 32rpx;
    margin: 0rpx 10rpx 0rpx 10rpx;
  }

  .codeLogin_fd3_0_c0_c0 {
    background: #EEEEEE;
    width: 156rpx;
    height: 1rpx;
    margin: 10rpx 0rpx 10rpx 0rpx;
    transform: scaleY(0.5);
    border-radius: 1rpx 1rpx 1rpx 1rpx;
  }
</style>
